<?php
/**
 * Created by PhpStorm.
 * User: sunshine
 * Date: 2016/8/31
 * Time: 18:11
 */

require 'Home/Model/Model.php';
class IndexModel extends Model{
    function __Construct(){
        parent::__Construct();
    }
    function getLogin($data){
        if($data['username']=='admin') {
            $sql = "select * from admin where admin='" . $data['username'] . "' and pw='" .md5($data['password'])."'";
          // echo $sql;
            $d= $this->conn->query($sql);

            return $d;
        }
        else{
            $sql = "select * from student where sname='" . $data['username'] . "'  and password='" .md5($data['password'])."'";
          //  echo $sql;
            $d = $this->conn->query($sql);
            return $d;
        }
    }
    function addType($data){

        $type = array(
            'typename' => trim($data['typename'])
        );
        $keys = implode(',',array_keys($type));
        $values = implode("','", array_values($type));
        $sql="insert into type ({$keys}) VALUES ('{$values}')";
        //执行SQL语句
        $d = $this->conn->query($sql);
        return $d;
    }

}

?>